﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using SnakeWalk.Interfaces;

namespace SnakeWalk.Painter
{
	public class SnakePainter
	{
		private SnakePainter() { }

		// Paint Snake
		private Snake snake;
		private Bait bait;
		// On What (Graphics)
		private Graphics gp;

		// Draw Paint
		private IBodyPaint bodyPaint;
		private IBaitPaint baitPaint;

		public SnakePainter(Snake snake, Bait bait, Control control)
		{
			this.snake = snake;
			this.bait = bait;

			gp = control.CreateGraphics();
			bodyPaint = new BodyDraw(gp, new Point(0, 0), new Size((int)SizeAndBaitSnake.Width, (int)SizeAndBaitSnake.Height));
			baitPaint = new BaitDraw(gp, new Point(0, 0), new Size((int)SizeAndBaitSnake.Width, (int)SizeAndBaitSnake.Height));

			gp.Clear(Color.Beige);
		}

		public void PaintSnake()
		{
			gp.Clear(Color.Beige);
			for (int i = 0; i < snake.SnakeBodies.Count; i++)
			{
				bodyPaint.Moving(new Point(snake.SnakeBodies[i].Position.X, snake.SnakeBodies[i].Position.Y));
			}
		}

		public void PaintBait()
		{
			baitPaint.Appear(new Point(bait.Position.X, bait.Position.Y));
		}
	}
}
